package com.heima.wemedia.controller.v1;

import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmPageDto;
import com.heima.wemedia.service.WmChannelService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.ResourceBundle;

@RestController
@Slf4j
@RequestMapping("/api/v1/channel")
@RequiredArgsConstructor
public class WmchannelController {

    private final WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult findAll(){
        return wmChannelService.findAll();
    }

    @GetMapping("/del/{id}")
    public ResponseResult del(@PathVariable Integer id){
        return wmChannelService.del(id);
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmPageDto dto){
        return wmChannelService.listByname(dto);
    }

    @PostMapping("/save")
    public ResponseResult save(@RequestBody AdChannel adChannel){
        return wmChannelService.insert(adChannel);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannel adChannel){
        return wmChannelService.updateByChannel(adChannel);
    }


}
